package cn.tedu.cake.controller;

import cn.tedu.cake.pojo.dto.CategoryDTO;
import cn.tedu.cake.pojo.dto.ShoppingDTO;
import cn.tedu.cake.pojo.entity.Shopping;
import cn.tedu.cake.service.ICategoryService;
import cn.tedu.cake.service.ShoppingService;
import cn.tedu.cake.web.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/shoppings")
@Api(tags = "03. 购物车类型管理")
public class ShoppingController {

    @Autowired
    private ShoppingService shoppingService;

    @PostMapping("/add-new")
    @ApiOperation("添加购物车")
    public JsonResult addNew(ShoppingDTO shoppingDTO){
        shoppingService.addNew(shoppingDTO);
        return JsonResult.ok();
    }

    @PostMapping("/deleteById")
    @ApiOperation("根据ID删除购物车")
    public JsonResult deleteById(int id){
        shoppingService.deleteById(id);
        return JsonResult.ok();
    }

    @PostMapping("/update")
    @ApiOperation("根据用户ID修改购物车")
    public JsonResult updateByUserId(Shopping shopping){
        shoppingService.update(shopping);
        return JsonResult.ok();
    }


}
